home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 14 / CU Amiga Magazine's Super CD-ROM 14 (1997)(EMAP Images)(GB)(Track 1 of 3)[!][issue 1997-09].iso / CUCD / Programming / AMOS / rjkpro_1 / marioclone.amos / marioclone.amosSourceCode < prev    next >
Encoding:
AMOS Source Code  |  1997-04-02  |  3.5 KB  |  262 lines

  1. '----------------------------------------------------
  2. '                  mario clone v1.1  
  3. '----------------------------------------------------
  4. '               keller@vip.cybercity.dk
  5. '                     rune keller  
  6. '                 sporuplundsvej 105 
  7. '                   dk-8472 sporup 
  8. '----------------------------------------------------
  9. '            finished o2/o4/1997 13:41:26
  10. '----------------------------------------------------  
  11.  
  12. 'set up a screen 
  13.  
  14. Screen Open 0,320,256,32,Lowres
  15. Flash Off 
  16. Curs Off 
  17. Hide 
  18. Cls 0
  19.  
  20. Get Sprite Palette 
  21.  
  22.  
  23.  
  24. 'use a double buffered screen
  25.  
  26. Double Buffer 
  27. Autoback 1
  28. Update Off 
  29.  
  30.  
  31.  
  32. 'draw a line for the hero to walk on 
  33.  
  34. Ink 7
  35. Draw 0,224 To 319,224
  36.  
  37.  
  38.  
  39. 'the walking speed of the hero. should be 1,2 or 4 
  40.  
  41. _SPEED=2
  42.  
  43.  
  44.  
  45. 'the max time the player must increase the height of a jump
  46.  
  47. _MAXTIME=6
  48.  
  49.  
  50.  
  51. 'the max height of a jump. in pixels a value of eg. 6 would
  52. 'mean an actual height of _MAXTIME*6+5+4+3+2+1 
  53.  
  54. _JUMPMAX=5
  55.  
  56.  
  57.  
  58. 'the speed of jump or just the gravity. should be 1,2,3 or 4   
  59.  
  60. _JUMPSPEED=3
  61.  
  62.  
  63.  
  64. 'frame rate of hero's walk animation. 1 = fastest
  65.  
  66. _ANIMATIONSPEED=4
  67.  
  68.  
  69.  
  70. 'hero's x and y positions
  71.  
  72. _HEROX=10*16
  73. _HEROY=14*16
  74.  
  75.  
  76.  
  77. 'which way is hero facing? -1 = left, 1 = right
  78.  
  79. _FACING=1
  80.  
  81.  
  82.  
  83. 'main loop 
  84.  
  85. Do 
  86.    
  87.    
  88.    
  89.    'reset variables 
  90.  
  91.    _UP=False
  92.    _DOWN=False
  93.    _LEFT=False
  94.    _RIGHT=False
  95.    _FIRE=False
  96.    
  97.  
  98.  
  99.    'get player input
  100.  
  101.    If Joy(1) and %10000 or Key State(76)
  102.       _UP=True
  103.    End If 
  104.    
  105.    If Joy(1) and %100 or Key State(79)
  106.       _LEFT=True
  107.    Else If Joy(1) and %1000 or Key State(78)
  108.       _RIGHT=True
  109.    End If 
  110.    
  111.    
  112.    
  113.    'reset to frame 1 if no input from player is received
  114.  
  115.    If _UP=False and _DOWN=False and _LEFT=False and _RIGHT=False and _FIRE=False
  116.       _FRAME=1
  117.    End If 
  118.    
  119.  
  120.  
  121.    'if player walks left
  122.  
  123.    If _LEFT=True
  124.       
  125.  
  126.  
  127.       'update animation
  128.  
  129.       If Timer mod _ANIMATIONSPEED=0 or _FRAME<2 or _FRAME>7
  130.          Add _FRAME,1,2 To 7
  131.       End If 
  132.       
  133.       _FACING=-1
  134.       
  135.  
  136.  
  137.       'move hero left
  138.  
  139.       If _HEROX-_SPEED=>10
  140.          _HEROX=_HEROX-_SPEED
  141.       End If 
  142.       
  143.  
  144.  
  145.       'if player walks right 
  146.  
  147.    Else If _RIGHT=True
  148.       
  149.  
  150.  
  151.       'update animation
  152.  
  153.       If Timer mod _ANIMATIONSPEED=0 or _FRAME<2 or _FRAME>7
  154.          Add _FRAME,1,2 To 7
  155.       End If 
  156.       
  157.       _FACING=1
  158.       
  159.  
  160.  
  161.       'move hero right 
  162.  
  163.       If _HEROX+_SPEED<=310
  164.          _HEROX=_HEROX+_SPEED
  165.       End If 
  166.       
  167.    End If 
  168.    
  169.  
  170.  
  171.    'if player jumps   
  172.  
  173.    If _UP=True and _TIME<_MAXTIME
  174.       
  175.  
  176.  
  177.       'if player is not already jumping
  178.  
  179.       If _JUMPING=False
  180.          
  181.          _JUMPING=True
  182.          _JUMPMOVE=-_JUMPMAX*_JUMPSPEED
  183.          
  184.       End If 
  185.       
  186.  
  187.  
  188.       'move hero up
  189.  
  190.       _HEROY=_HEROY+_JUMPMOVE/_JUMPSPEED
  191.       Inc _TIME
  192.       
  193.    Else 
  194.       
  195.  
  196.  
  197.       'change jump offset
  198.  
  199.       If _JUMPMOVE<_JUMPMAX*_JUMPSPEED+1
  200.          _JUMPMOVE=_JUMPMOVE+1
  201.       End If 
  202.       
  203.    End If 
  204.    
  205.  
  206.  
  207.    'if player is jumping
  208.  
  209.    If _JUMPING=True
  210.       
  211.  
  212.  
  213.       'change frame to jump animation
  214.  
  215.       _FRAME=8
  216.       
  217.  
  218.  
  219.       'if hero falls down onto the line
  220.  
  221.       If _HEROY+_JUMPMOVE/_JUMPSPEED=>14*16
  222.          
  223.          _HEROY=14*16
  224.          _JUMPING=False
  225.          _TIME=0
  226.          
  227.       Else 
  228.          
  229.  
  230.  
  231.          'move hero up/down 
  232.  
  233.          _HEROY=_HEROY+_JUMPMOVE/_JUMPSPEED
  234.          
  235.       End If 
  236.       
  237.    End If 
  238.    
  239.    
  240.    
  241.    'display hero
  242.  
  243.    If _FACING=1
  244.       Bob 0,_HEROX,_HEROY,_FRAME
  245.    Else If _FACING=-1
  246.       Bob 0,_HEROX,_HEROY,_FRAME+$8000
  247.    End If 
  248.    
  249.    
  250.    
  251.    'update screen 
  252.  
  253.    Bob Draw 
  254.    Wait Vbl 
  255.    Screen Swap 
  256.    Bob Clear 
  257.    
  258.    
  259.    
  260.    'end loop
  261.  
  262. Loop